﻿layui.use(['layer', 'element'], function () {
    var $ = layui.jquery
    , element = layui.element()
    , layer = layui.layer;

    element.on('tab(unpaid)', function (data) {
        var state = parseInt(data.index);
        if (state >= 2) {
            state = state + 1;
        }
        $.ajax({
            url: '/ClientCenter/GetOrdersByState',
            type: 'post',
            data: {
                state:state,
            },
            success: function (data) {
                var html = $('#order_template').render(data.orders);
                $('.layui-show').html(html);
            }
        })
    });

    $('.get-order-bt').click(function () {
        var bt = $(this);
        var id = $(this).parent().children('input[type="hidden"]').val();
        var parent = $(this).parent().parent().parent();
        $.ajax({
            url: '/ClientCenter/OrderConfirm',
            type: 'POST',
            data: { orderId: id },
            success: function (data) {
                if (data.success != "") {
                    layer.msg(data.success);
                    
                }
                else if (data.error != "") {
                    layer.msg(data.error);
                }

            }
        })

    })
})